Micron Document
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| SparkN0de-git | SparkN0de |
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Commit 8d72a83411a7a3890c905ce919dd267d61471d82


Parents : 0fb9e18
Author : Mark Qvist <mark@unsigned.io>
Date : 2023-10-16T00:51:23+02:00

Added option to disable propagation node for pageserving-only nodes

Changes

3 files changed, 68 insertions(+), 13 deletions(-)


Diff

diff --git a/nomadnet/NomadNetworkApp.py b/nomadnet/NomadNetworkApp.py
index f17c31c..c966665 100644
--- a/nomadnet/NomadNetworkApp.py
+++ b/nomadnet/NomadNetworkApp.py
@@ -122,6 +122,7 @@ class NomadNetworkApp:
self.peer_announce_at_start = True
self.try_propagation_on_fail = True
+ self.disable_propagation = False
self.periodic_lxmf_sync = True
self.lxmf_sync_interval = 360*60
@@ -308,15 +309,27 @@ class NomadNetworkApp:
except Exception as e:
RNS.log("Cannot prioritise "+str(dest_str)+", it is not a valid destination hash", RNS.LOG_ERROR)
- self.message_router.enable_propagation()
- try:
- with open(self.pnannouncedpath, "wb") as pnf:
- pnf.write(msgpack.packb(time.time()))
- pnf.close()
- except Exception as e:
- RNS.log("An error ocurred while writing Propagation Node announce timestamp. The contained exception was: "+str(e), RNS.LOG_ERROR)
+ if self.disable_propagation:
+ if os.path.isfile(self.pnannouncedpath):
+ try:
+ RNS.log("Sending indication to peered LXMF Propagation Node that this node is no longer participating", RNS.LOG_DEBUG)
+ self.message_router.disable_propagation()
+ os.unlink(self.pnannouncedpath)
+ except Exception as e:
+ RNS.log("An error ocurred while indicating that this LXMF Propagation Node is no longer participating. The contained exception was: "+str(e), RNS.LOG_ERROR)
+ else:
+ self.message_router.enable_propagation()
+ try:
+ with open(self.pnannouncedpath, "wb") as pnf:
+ pnf.write(msgpack.packb(time.time()))
+ pnf.close()
+
+ except Exception as e:
+ RNS.log("An error ocurred while writing Propagation Node announce timestamp. The contained exception was: "+str(e), RNS.LOG_ERROR)
- RNS.log("LXMF Propagation Node started on: "+RNS.prettyhexrep(self.message_router.propagation_destination.hash))
+ if not self.disable_propagation:
+ RNS.log("LXMF Propagation Node started on: "+RNS.prettyhexrep(self.message_router.propagation_destination.hash))
+
self.node = nomadnet.Node(self)
else:
self.node = None
@@ -788,6 +801,11 @@ class NomadNetworkApp:
else:
self.node_name = self.config["node"]["node_name"]
+ if not "disable_propagation" in self.config["node"]:
+ self.disable_propagation = False
+ else:
+ self.disable_propagation = self.config["node"].as_bool("disable_propagation")
+
if not "announce_at_start" in self.config["node"]:
self.node_announce_at_start = False
else:
@@ -1003,6 +1021,14 @@ announce_interval = 360
# Whether to announce when the node starts.
announce_at_start = Yes
+# By default, when Nomad Network is hosting a
+# node, it will also act as an LXMF propagation
+# node. If there is already a large amount of
+# propagation nodes on the network, or you
+# simply want to run a pageserving-only node,
+# you can disable running a propagation node.
+# disable_propagation = False
+
# The maximum amount of storage to use for
# the LXMF Propagation Node message store,
# specified in megabytes. When this limit

diff --git a/nomadnet/ui/textui/Guide.py b/nomadnet/ui/textui/Guide.py
index 954cbd2..67aa856 100644
--- a/nomadnet/ui/textui/Guide.py
+++ b/nomadnet/ui/textui/Guide.py
@@ -620,6 +620,12 @@ Determines where the node server will look for hosted pages. Must be a readable
Determines where the node server will look for downloadable files. Must be a readable filesystem path.
<
+>>>
+`!disable_propagation = no`!
+>>>>
+By default, when Nomad Network is hosting a node, it will also run an LXMF propagation node. If there is already a large amount of propagation nodes on the network, or you simply want to run a pageserving-only node, you can disable running a propagation node.
+<
+
>>>
`!message_storage_limit = 2000`!
>>>>

diff --git a/nomadnet/ui/textui/Network.py b/nomadnet/ui/textui/Network.py
index 6d54762..56b7d3b 100644
--- a/nomadnet/ui/textui/Network.py
+++ b/nomadnet/ui/textui/Network.py
@@ -977,12 +977,12 @@ class NodeStorageStats(urwid.WidgetWrap):
def update_stat(self):
self.stat_string = "None"
- if self.app.node != None:
+ if self.app.node != None and not self.app.disable_propagation:
limit = self.app.message_router.message_storage_limit
used = self.app.message_router.message_storage_size()
- if limit != None:
+ if limit != None and used != None:
pct = round((used/limit)*100, 1)
pct_str = str(pct)+"%, "
limit_str = " of "+RNS.prettysize(limit)
@@ -1313,12 +1313,35 @@ class NodeInfo(urwid.WidgetWrap):
connect_button = urwid.Button("Browse", on_press=connect_query)
reset_button = urwid.Button("Rst Stats", on_press=stats_query)
- pile = urwid.Pile([
+ if not self.app.disable_propagation:
+ pile = urwid.Pile([
+ t_id,
+ e_name,
+ urwid.Divider(g["divider1"]),
+ e_lxmf,
+ urwid.Divider(g["divider1"]),
+ self.t_last_announce,
+ self.t_storage_stats,
+ self.t_active_links,
+ self.t_total_connections,
+ self.t_total_pages,
+ self.t_total_files,
+ urwid.Divider(g["divider1"]),
+ urwid.Columns([
+ ("weight", 5, urwid.Button("Back", on_press=show_peer_info)),
+ ("weight", 0.5, urwid.Text("")),
+ ("weight", 6, connect_button),
+ ("weight", 0.5, urwid.Text("")),
+ ("weight", 8, reset_button),
+ ("weight", 0.5, urwid.Text("")),
+ ("weight", 7, announce_button),
+ ])
+ ])
+ else:
+ pile = urwid.Pile([
t_id,
e_name,
urwid.Divider(g["divider1"]),
- e_lxmf,
- urwid.Divider(g["divider1"]),
self.t_last_announce,
self.t_storage_stats,
self.t_active_links,


──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────